<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>添加收款管理</title>
	<link rel="stylesheet" href="../css/from.css">
	<link rel="stylesheet" href="../themes/default/easyui.css">
	<link rel="stylesheet" href="../themes/icon.css">
	<script src="../js/jquery.min.js"></script>
	<script src="../js/jquery.easyui.min.js"></script>
	<script src="../js/easyui-lang-zh_CN.js"></script>
	<script>
		//撤销支收方法
		function revokeRealCollectBill() {
            $.messager.confirm('确认','您确认想要撤销吗？',function(r){
                if (r){
                    $.ajax({
                        url: "../../collectBillController/revokeRealCollectCurrentBill",
                        data: {code:$("#code").val()},
                        beforeSend:function(){
                            return true;
                        },
                        dataType:"text",
                        success:function(data){
                            alert(data);
                            $.ajax({
                                url: "../../collectBillController/findCollectBill",
                                data:{collectCode:$("#code").val()},
								dataType: "text",
								success: function (data) {
                                    window.location.href="collectbill_detail_checked.html";
                                }
                            });

                        }
                    });
                }
            });
        }

        /*生成excel表格的方法*/
        function getWord() {
            var code=$("#code").textbox('getText');
            /*$.ajax({
                url: "../../collectBillController/getExcel",
                data: {data:data}
            });*/
            $.messager.confirm('确认','您确认想要导出word文件吗？（下载路径为浏览器默认下载路径）',function(r) {
                if (r) {
                    location.href="../../collectBillController/getWord?code="+code;
                }
            });
        }

        //关闭当前这个页面
        function closeTab(){
            parent.tabsClose();
        }

        function ajaxLoading(){
            $("<div class=\"datagrid-mask\"></div>").css({display:"block",width:"100%",height:$(window).height()}).appendTo("body");
            $("<div class=\"datagrid-mask-msg\"></div>").html("正在处理，请稍候。。。").appendTo("body").css({display:"block",left:($(document.body).outerWidth(true) - 190) / 2,top:($(window).height() - 45) / 2});
        }
        function ajaxLoadEnd(){
            $(".datagrid-mask").remove();
            $(".datagrid-mask-msg").remove();
        }

        //已经没用的方法
        function revokeCollectBill() {
            $.messager.confirm('确认','您确认想要撤销吗？',function(r){
                if (r){
                    $.ajax({
                        url: "../../collectBillController/revokeCollectBill",
                        data: {code:$("#code").val()},
                        beforeSend:function(){
                            return true;
                        },
                        dataType:"text",
                        success:function(data){
                            alert(data);
                            $.ajax({
                                url: "../../collectBillController/findCollectBill",
                                data:{collectCode:$("#code").val()}
                            });
                            window.location.href="collectbill_detail.html";
                        }
                    });
                }
            });
        }

        $(function(){

            $('#form1').form('load','../../collectBillController/loadCollectBill');
            $("#code").textbox('readonly',true);
            $("#code").textbox('textbox').css('background','#CCCCCC');
            $("#supplierName").textbox("readonly",true);
            $("#supplierName").textbox('textbox').css('background','#CCCCCC');
            $("#type").textbox("readonly",true);
            $("#type").textbox('textbox').css('background','#CCCCCC');
            $("#addDate").datebox("readonly",true);
            $("#addDate").datebox('textbox').css('background','#CCCCCC');
            $("#contacter").combobox("readonly",true);
            $("#contacter").combobox('textbox').css('background','#CCCCCC');
            $("#fax").textbox("readonly",true);
            $("#fax").textbox('textbox').css('background','#CCCCCC');
            $("#productList").datagrid({
                fit:true,
                url:'../../collectBillController/loadOutstorageListByCollectBill',
                rownumbers:true,
                checkOnSelect:false,
                onSelect:function(rowIndex, rowData){  //用于解决点击某行不会高亮
                    $('#productList').datagrid('unselectRow',rowIndex);
                },
                columns:[[
                    {field:'billCode',title:'业务单号',width: 122},
                    {field: "a",title: "本方账目",width: 100,formatter: function (value,row,index) {
                            return "应收帐目";
                        }},
                    {field: "b",title: "本方增减",width: 100,formatter: function (value,row,index) {
                            return "增加";
                        }},
                    {field:'collectMoney',title:'应收金额',width: 100,formatter: function (value,row,index) {
                            return value;
                        }},
                    {field:'realMoney',title:'实收金额',width: 100,editor: 'numberbox'},
                    {field:'memo',title:'备注',editor: 'text',width: 100},
                    {field: "operation",title: "操作",width: 100,formatter:function(value,row,index){
                            return "<a id='a_id_"+index+"' href='#' onclick='deleteOutstorageBillInRow("+index+")'>删除</a>";
                        }}
                ]],
                pagination: false/* ,//向后台传递参数page 和rows
                pageNumber: 1,
                pageSize: 5,
                pageList: [5,10,20] */
            });
        })

	</script>
	<style>
		body {
			font-size:12px;
			padding:10px
		}
		.l-table-edit {
			border-collapse:collapse;
			border-spacing:0;
		}
		.l-table-edit-td {
			padding:4px;
			font-size:12px;
			border:1px solid #84a0c4
		}
	</style>


</head>
<body>
<form name="form1" id="form1" action="" method="post">
	<table cellpadding="0" cellspacing="0" class="l-table-edit" border="1"
		   style="width: 100%">
		<tr>
			<td width="17%" align="right" class="l-table-edit-td">收款单号：</td>
			<td width="27%" align="left" class="l-table-edit-td"><input
					class="easyui-textbox" name="code" type="text" id="code" size="30" style="height: 20px"/>
			<td width="13%" align="right" class="l-table-edit-td">收款日期：</td>
			<td width="43%" align="left" class="l-table-edit-td"><input
					class="easyui-datebox" type="text" id="addDate" name="collectDate"
					maxlength="30"  style="height: 20px"/></td>
		</tr>
		<tr>
			<td width="17%" align="right" class="l-table-edit-td"><a
					href="#" onclick="loadSupplier()">供应商名：</a></td>
			<td align="left" class="l-table-edit-td"><input
					class="easyui-textbox" type="text" id="supplierName" value=""
					size="30" maxlength="100" ltype="text" name="customName" style="height: 20px"/>
			<td width="13%" align="right" class="l-table-edit-td">收款方式：</td>
			<td align="left" class="l-table-edit-td"><select
					class="easyui-combobox" name="type" id="contacter"
					style="width: 160px;height: 20px">
				<option value="1">现金</option>
				<option value="2">转账</option>
			</select></td>
		</tr>
		<tr>
			<td width="17%" align="right" class="l-table-edit-td">收款金额：</td>
			<td align="left" class="l-table-edit-td"><input
					class="easyui-textbox" type="text" id="type" value="" size="30"
					maxlength="50" ltype="text" name="collectTotalMoney" style="height: 20px"/></td>
			<td width="17%" align="right" class="l-table-edit-td">备注：</td>
			<td align="left" class="l-table-edit-td"><input type="text" style="height: 20px"
															class="easyui-textbox" id="fax" value="" maxlength="50"
															ltype="text" name="memo" /></td>
		</tr>

	</table>
</form>
<br>
<input type="button" value="新   增" style="cursor:pointer;width: 60px" onclick="addProduct()">&ensp;
<input type="button" disabled="disabled" value="选出库单"
	   style="width: 60px">&ensp;
<input type="button" disabled="disabled" value="保      存"
	   style="width: 60px">&ensp;
<input type="button" disabled="disabled" value="审      核"
	   style="width: 60px">&ensp;
<input type="button" value="撤销审核" style="cursor:pointer;width: 60px"
	   onclick="" disabled="disabled">&ensp;
<input
		type="button" value="收       款" style="cursor:pointer;width: 60px"
		onclick="" disabled="disabled">
<input
		type="button" value="撤销收款" style="cursor:pointer;width: 60px"
		onclick="revokeRealCollectBill()">
<input type="button" value="打     印" style="cursor:pointer;width: 60px" onclick="getWord()">&ensp;
<input type="button" value="关     闭" style="cursor:pointer;width: 60px" onclick="closeTab()">&ensp;
<div id="p" style="width: 400px;"></div>
<div id="productList" class="easyui-datagrid"></div>
</body>
</html>